package pl.edu.mimuw.irs.core.model.design.exception;

/**
 * @author Jakub Rauch
 * Created on: 2009-05-07
 */
public class InternalIRSException extends RuntimeException {

	// *** Attributes

	// Required id
	private static final long serialVersionUID = -971661464060465302L;
	// Cause of this exception
	private Cause cause;
	private String[] opts;
	
	// *** Methods
	
	public InternalIRSException(Cause cause, String... opts) {
		this.cause = cause;
		this.opts = opts;
	}
	
	@Override
	public String toString() {
		StringBuffer stringBuffer = new StringBuffer();
		stringBuffer.append("InternalException." + cause.toString());
		if (opts != null && opts.length > 0) {
			stringBuffer.append("[");
			for (String opt : opts) {
				stringBuffer.append(opt);
				stringBuffer.append(",");
			}
			stringBuffer.replace(stringBuffer.lastIndexOf(","), 
					stringBuffer.length(), "]");
		}
		
		return stringBuffer.toString();
	}

	// *** Enums

	public enum Cause {
		UNKNOWN_NODE_TYPE, 
		UNSUPPORTED_FRAGMENTATION_TYPE, 
		NOT_ALLOWED_ARC_NODES, 
		NOT_IRS_ARC, 
		NOT_IRS_NODE, 
		NOT_IRS_PLACE, 
		NOT_IRS_TRANSITION,
		NOT_IRS_RESOURCE_SET;
	}
}
